﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace S.M.SmartMedical.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class UpdateCarouselTable : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_Carousels_CreateTime",
                table: "Carousels");

            migrationBuilder.DropIndex(
                name: "IX_Carousels_EffectiveEndTime",
                table: "Carousels");

            migrationBuilder.DropIndex(
                name: "IX_Carousels_EffectiveStartTime",
                table: "Carousels");

            migrationBuilder.DropIndex(
                name: "IX_Carousels_IsEnabled",
                table: "Carousels");

            migrationBuilder.DropIndex(
                name: "IX_Carousels_Type",
                table: "Carousels");

            migrationBuilder.DropColumn(
                name: "AltText",
                table: "Carousels");

            migrationBuilder.DropColumn(
                name: "CssClass",
                table: "Carousels");

            migrationBuilder.DropColumn(
                name: "ExtensionData",
                table: "Carousels");

            migrationBuilder.DropColumn(
                name: "IsEnabled",
                table: "Carousels");

            migrationBuilder.DropColumn(
                name: "Type",
                table: "Carousels");

            migrationBuilder.RenameColumn(
                name: "ClickCount",
                table: "Carousels",
                newName: "Status");

            migrationBuilder.UpdateData(
                table: "Carousels",
                keyColumn: "LinkUrl",
                keyValue: null,
                column: "LinkUrl",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "LinkUrl",
                table: "Carousels",
                type: "varchar(500)",
                maxLength: 500,
                nullable: false,
                oldClrType: typeof(string),
                oldType: "varchar(500)",
                oldMaxLength: 500,
                oldNullable: true)
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.UpdateData(
                table: "Carousels",
                keyColumn: "Description",
                keyValue: null,
                column: "Description",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "Description",
                table: "Carousels",
                type: "varchar(500)",
                maxLength: 500,
                nullable: false,
                oldClrType: typeof(string),
                oldType: "varchar(500)",
                oldMaxLength: 500,
                oldNullable: true)
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<DateTime>(
                name: "UploadTime",
                table: "Carousels",
                type: "datetime(6)",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<string>(
                name: "Uploader",
                table: "Carousels",
                type: "varchar(50)",
                maxLength: 50,
                nullable: false,
                defaultValue: "")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_Carousels_Status",
                table: "Carousels",
                column: "Status");

            migrationBuilder.CreateIndex(
                name: "IX_Carousels_UploadTime",
                table: "Carousels",
                column: "UploadTime");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_Carousels_Status",
                table: "Carousels");

            migrationBuilder.DropIndex(
                name: "IX_Carousels_UploadTime",
                table: "Carousels");

            migrationBuilder.DropColumn(
                name: "UploadTime",
                table: "Carousels");

            migrationBuilder.DropColumn(
                name: "Uploader",
                table: "Carousels");

            migrationBuilder.RenameColumn(
                name: "Status",
                table: "Carousels",
                newName: "ClickCount");

            migrationBuilder.AlterColumn<string>(
                name: "LinkUrl",
                table: "Carousels",
                type: "varchar(500)",
                maxLength: 500,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "varchar(500)",
                oldMaxLength: 500)
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "Description",
                table: "Carousels",
                type: "varchar(500)",
                maxLength: 500,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "varchar(500)",
                oldMaxLength: 500)
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "AltText",
                table: "Carousels",
                type: "varchar(200)",
                maxLength: 200,
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "CssClass",
                table: "Carousels",
                type: "varchar(100)",
                maxLength: 100,
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "ExtensionData",
                table: "Carousels",
                type: "varchar(1000)",
                maxLength: 1000,
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<bool>(
                name: "IsEnabled",
                table: "Carousels",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<string>(
                name: "Type",
                table: "Carousels",
                type: "varchar(50)",
                maxLength: 50,
                nullable: true)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_Carousels_CreateTime",
                table: "Carousels",
                column: "CreateTime");

            migrationBuilder.CreateIndex(
                name: "IX_Carousels_EffectiveEndTime",
                table: "Carousels",
                column: "EffectiveEndTime");

            migrationBuilder.CreateIndex(
                name: "IX_Carousels_EffectiveStartTime",
                table: "Carousels",
                column: "EffectiveStartTime");

            migrationBuilder.CreateIndex(
                name: "IX_Carousels_IsEnabled",
                table: "Carousels",
                column: "IsEnabled");

            migrationBuilder.CreateIndex(
                name: "IX_Carousels_Type",
                table: "Carousels",
                column: "Type");
        }
    }
}
